package com.lx.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.lx.annotation.Note;
import com.lx.util.LX;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;
import java.util.Set;

import static com.lx.constant.DefaultBaseConstant.ADMIN_USER_TYPE;

@Data
@Schema(name = "用户信息")
@Builder
@AllArgsConstructor
public class UserInfo implements Serializable {

    public static final long serialVersionUID = 50009944212722661L;
    @Schema(description="用户ID")
    @NotNull(message = "用户id不能为空!")
    private String userId;

    @Schema(description="用户类型")
    private String userType;

    @Schema(description="用户颁发token时类型, 类型一致会删掉用户之前的token")
    private String tokenType;

    @Schema(description="权限ID,接口权限使用")
    private String permissionId;

    @Schema(name = "token")
    private String token;

    public UserInfo() {
    }
    public UserInfo(String userId, String userType) {
        this.userId = userId;
        this.userType = userType;
        this.tokenType = userType;
    }

    public UserInfo(String userId, String userType, String tokenType, String permissionId) {
        this.userId = userId;
        this.userType = userType;
        this.tokenType = tokenType;
        this.permissionId = permissionId;
    }

    @Note("是否为超级管理员")
    public boolean superAdmin(){
        return ADMIN_USER_TYPE.equals(userType);
    }
}
